/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * Referee.java
 *
 * Created on 17 avr. 2012, 17:38:10
 */
package debate.gui;

import debate.game.Referee;
import debate.logical.Argument;
import java.awt.Dimension;
import java.awt.Toolkit;
import javax.swing.DefaultListModel;
import javax.swing.JButton;
import javax.swing.JList;

/**
 *
 * @author Propriétaire
 */
public class RefereePane extends javax.swing.JPanel {

    private Referee referee;

    /** Creates new form Referee */
    public RefereePane() {
        initComponents();
        referee = new Referee();
        formulasJList.setModel(new DefaultListModel());
        argumentsJList.setModel(new DefaultListModel());
        formulasJList.setCellRenderer(new ListCellRendererForFormula());
        argumentsJList.setCellRenderer(new ListCellRendererForArgument());
    }

    public JButton getNewGameButton() {
        return newGameJButton;
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jProgressBar1 = new javax.swing.JProgressBar();
        jSeparator1 = new javax.swing.JSeparator();
        newGameJButton = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        formulasJList = new javax.swing.JList();
        jScrollPane4 = new javax.swing.JScrollPane();
        argumentsJList = new javax.swing.JList();

        setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Referee", javax.swing.border.TitledBorder.CENTER, javax.swing.border.TitledBorder.TOP, new java.awt.Font("Dialog", 1, 18))); // NOI18N

        jProgressBar1.setName("jProgressBar1"); // NOI18N

        jSeparator1.setName("jSeparator1"); // NOI18N

        newGameJButton.setText("New game");
        newGameJButton.setName("newGameJButton"); // NOI18N

        jScrollPane3.setName("jScrollPane3"); // NOI18N

        formulasJList.setBorder(javax.swing.BorderFactory.createTitledBorder("Common Formulas"));
        formulasJList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        formulasJList.setName("formulasJList"); // NOI18N
        jScrollPane3.setViewportView(formulasJList);

        jScrollPane4.setName("jScrollPane4"); // NOI18N

        argumentsJList.setBorder(javax.swing.BorderFactory.createTitledBorder("Common Arguments"));
        argumentsJList.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        argumentsJList.setName("argumentsJList"); // NOI18N
        jScrollPane4.setViewportView(argumentsJList);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(newGameJButton)
                        .addGap(18, 18, 18)
                        .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addContainerGap(49, Short.MAX_VALUE))
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 302, Short.MAX_VALUE)))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGap(8, 8, 8)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(newGameJButton)
                    .addComponent(jProgressBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 16, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 148, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(114, 114, 114))
        );
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JList argumentsJList;
    private javax.swing.JList formulasJList;
    private javax.swing.JProgressBar jProgressBar1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JSeparator jSeparator1;
    private javax.swing.JButton newGameJButton;
    // End of variables declaration//GEN-END:variables

    public JList getArgumentsJList() {
        return argumentsJList;
    }

    public JList getFormulasJList() {
        return formulasJList;
    }

    public Referee getReferee() {
        return referee;
    }

    public void refreshModel() {
        ((DefaultListModel) formulasJList.getModel()).clear();
        for (String s : referee.getFormulaList()) {
            ((DefaultListModel) formulasJList.getModel()).addElement(s);
        }
        ((DefaultListModel) argumentsJList.getModel()).clear();
        for (Argument a : referee.getArgumentList()) {
            ((DefaultListModel) argumentsJList.getModel()).addElement(a);
        }
    }
}
